#include <list>
#include <winsock2.h>
#include "log4cplus_switch.h"
#include "timer.h"
#include "timer_manager.h"

LOG4CPLUS_CLASS_IMPLEMENT( CTimer, _s_logger, "CTimer" );

CTimer::CTimer(unsigned int vinterval,void (*vfunc)(CTimer *,void *),void *vdata,TimerType vtype):

	m_interval(vinterval),m_state(TIMER_IDLE),m_type(vtype),
	m_func(vfunc),m_data(vdata)
{}
void CTimer::start()
{
	CTimerManager::instance()->add_timer(this);
}
void CTimer::stop()
{
	CTimerManager::instance()->remove_timer(this);
}
void CTimer::reset(unsigned int vinterval)
{
	CTimerManager::instance()->remove_timer(this);
	m_interval=vinterval;
	CTimerManager::instance()->add_timer(this);
}
CTimer::~CTimer()
{
	if(m_state==TIMER_ALIVE)
		stop();
}


